﻿namespace ufida.u9.ait.openapi
{
	using System;
	using System.Collections.Generic;
    using System.Text;
    using ufida.u9.ait.openapi.utils;
    using UFIDA.U9.CBO.Pub.Controller;
    using UFIDA.U9.InvDoc.CheckDiffBill;
    using UFIDA.U9.InvDoc.Enums;
    using UFIDA.U9.ISV.CheckDiffSV;
    using UFSoft.UBF.AopFrame;
    using UFSoft.UBF.Business;
    using UFSoft.UBF.Util.Context;

    /// <summary>
    /// CheckDiffApproveSV partial 
    /// </summary>	
    public partial class CheckDiffApproveSV
    {
        internal BaseStrategy Select()
        {
			return new CheckDiffApproveSVImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class CheckDiffApproveSVImpementStrategy : BaseStrategy
	{
		public CheckDiffApproveSVImpementStrategy() { }

		public override object Do(object obj)
		{						
			CheckDiffApproveSV bpObj = (CheckDiffApproveSV)obj;

            //try
            //{
            //    if (bpObj.Data == null || bpObj.Data.Count == 0)
            //        throw new Exception("传入参数为空");
            //    List<CommonArchiveDataDTOData> retlist = new List<CommonArchiveDataDTOData>();

            //    foreach (var dto in bpObj.Data)
            //    {
            //        CheckDiffBill item = CheckDiffBill.Finder.Find($"DocNo='{dto.DocNo}'");
            //        if (item == null)
            //        {
            //            //新增逻辑
            //            throw new Exception($"单号:{dto.DocNo}不存在!");
            //        }
            //        else
            //        {
            //            //修改逻辑
            //            if (item.Status != INVDocStatus.Approving)
            //                throw new Exception($"单号[{item.DocNo}]状态不为审核中");

            //            CheckDiffOperationSV sv = new CheckDiffOperationSV();
            //            sv.CheckDiffList = new List<CheckDiffBill.EntityKey>()
            //            {
            //                item.Key
            //            };
            //            sv.Status = INVDocStatus.Approved;

            //            CommonArchiveDataDTOData ret = new CommonArchiveDataDTOData()
            //            {
            //                ID = item.ID,
            //                Code = item.DocNo,
            //            };
            //            retlist.Add(ret);
            //        }
            //    }
            //    return ResultUtils.success(bpObj, bpObj.Data, retlist);
            //}
            //catch (Exception ex)
            //{
            //    return ResultUtils.error(bpObj, bpObj.Data, ex);
            //}

            return CodeUtils.DocUpdateRT<DocDTOData, CheckDiffBill>(bpObj, bpObj.Data, CheckDiffBase.ApproveDoc);
        }		
	}

	#endregion
	
	
}